# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: mrxx <mrxx at cyberhome dot at>
# Contributor: Evgeny Kurnevsky <kurnevsky@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=motion
pkgver=4.5.1
pkgrel=2
pkgdesc="Monitor and record video signals from many types of cameras"
arch=('loong64' 'x86_64')
license=('GPL')
url="https://motion-project.github.io"
depends=('sqlite' 'ffmpeg' 'libmicrohttpd' 'libwebp' 'mariadb-libs')
optdepends=('gettext: native language support')
backup=('etc/motion/motion.conf')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Motion-Project/motion/archive/release-$pkgver.tar.gz"
        'motion.service'
        'motion.sysusers'
        'motion.tmpfiles')
sha512sums=('3b8b60ad4f41c37cc215aa575b0295ee99b15f2d32cbf3393c0f7cdd8d87616cca1c00e11cb7bf74e4afa285caa094f08df3ba62ab21dcb28a48336e3ff5803e'
            '817590421b313f468b0ecc783048affa2a97e82701c6c18ab14b0215a5ed66bd5e66fe584441f161cdea334323e998151a255ebb615f15d5118bc6981876f273'
            '6223040c71d5d8e1a67ad99276342cb43549554191fba6492803f6d7069ea87afd378fec7a4c5332821a366d5a669fbd21f2aa16bb8911eabb45f44a18a65de5'
            'cae88686417c31984c56d0df6625fb4ee62c2910d7f45b0e46dc1de6775b1a7b5463efc3ad1299e44746317332100c6afb6526b68fa6abea23e86b62d897460b')

build() {
  cd $pkgname-release-$pkgver
  autoreconf -fi
  ./configure --prefix=/usr \
    --without-pgsql \
    --without-mysql \
    --sysconfdir=/etc \
    --with-ffmpeg \
    --with-webp
  make
}

package(){
  cd $pkgname-release-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 data/motion-dist.conf "$pkgdir"/etc/motion/motion.conf
  install -Dm644 "$srcdir"/motion.service "$pkgdir"/usr/lib/systemd/system/motion.service
  install -Dm644 "$srcdir"/motion.sysusers "$pkgdir"/usr/lib/sysusers.d/motion.conf
  install -Dm644 "$srcdir"/motion.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/motion.conf
}
